#define _CRT_SECURE_NO_WARNINGS 1

#include <string>
#include <map>

using namespace std;

class Solution {
public:
    int firstUniqChar(string s) {
        map<char, int> cmap;
        for (const auto& e : s)
        {
            cmap[e]++;
        }
        char c = '\0';
        for (int i = 0; i < s.size(); ++i)
        {
            if (cmap[s[i]] == 1)
                return i;
        }
        return -1;
    }
};